<?php 
/****
author:N++
email:
license:
****/

namespace Admin\Model;
use Think\Model;

class GoodsModel extends Model{
	protected $cates =[];

	public function __construct(){
		parent::__construct();
		$this->select();
	}
	//获取栏目树
	public function getTree( $parent_id=0 , $level=0 ){
		$tree = [];
		foreach($this->cates as $c){// 循环取cates数组里的值
			if($c['parent_id'] == $parent_id){
				$c['level'] = $level;
				$tree[] = $c;

				//然后,继续查这个cat_id的parent_id下面的
				$tree = arraymerge($tree , $this->getTree( $c['cat_id'] , $level+1 ));
			}
		}
		return $tree;
	}

	// 查询goods表
	// public function lists(){
	// 	return field('goods_id,goods_name,goods_sn,shop_price,click_count,goods_number,is_on_sale,is_delete,is_new,is_best,is_hot')->where(['is_delete'=>0])->limit($Page->firstRow,$Page->listRows)->select();
	// }

	//数据放入回收站
	public function del($getid){
		return $this->where(['goods_id'=>$getid])->save(['is_delete'=>1]);//删除地址栏上传来的id(将该id的is_delete 值改为1)
	}



}

?>